package com.yunche.yunchebusiness.ui.adapter

import android.app.Activity
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yunche.yunchebusiness.R
import com.yunche.yunchebusiness.entity.Brand

/**
 * Create by Crcker on 2018/12/21 11:34
 * Email: Crcker@163.com
 */


class BrandAdapter constructor(data: List<Brand>) : BaseMultiItemQuickAdapter<Brand, BaseViewHolder>(data) {

    init {
        addItemType(0, R.layout.item_brand)
        addItemType(1, R.layout.item_brand_index)
    }

    override fun convert(helper: BaseViewHolder?, item: Brand?) {

        when (helper?.itemViewType) {
            0 -> {
                helper!!.setText(R.id.tv_brand_title, item!!.name)
                Glide.with(mContext as Activity).load(item!!.icon).into(helper.getView(R.id.iv_brand_cover))
            }

            1 -> {
                helper!!.setText(R.id.tv_brand_title, item!!.initial)
            }
        }

    }
}
